/*!
 * LMV v6.4.1
 * 
 * Copyright 2019 Autodesk, Inc.
 * All rights reserved.
 * 
 * This computer source code and related instructions and comments are the
 * unpublished confidential and proprietary information of Autodesk, Inc.
 * and are protected under Federal copyright and state trade secret law.
 * They may not be disclosed to, copied or used by any third party without
 * the prior written consent of Autodesk, Inc.
 * 
 * Autodesk Forge Viewer Usage Limitations:
 * 
 * The Autodesk Forge viewer can only be used to view files generated by
 * Autodesk Forge services. The Autodesk Forge Viewer JavaScript must be
 * delivered from an Autodesk hosted URL.
 */
Autodesk.Extensions.MemoryManager =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./extensions/MemoryManager/MemoryManager.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./extensions/MemoryManager/MemoryManager.js":
/*!***************************************************!*\
  !*** ./extensions/MemoryManager/MemoryManager.js ***!
  \***************************************************/
/*! exports provided: MemoryManager */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MemoryManager", function() { return MemoryManager; });
/* harmony import */ var _MemoryManagerUI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./MemoryManagerUI */ "./extensions/MemoryManager/MemoryManagerUI.js");


var av = Autodesk.Viewing,
ave = av.Extensions,
avu = av.UI;

function MemoryManager(viewer, options) {
  av.Extension.call(this, viewer, options);
  this.name = 'memorymanager';
};

MemoryManager.prototype = Object.create(av.Extension.prototype);
MemoryManager.prototype.constructor = MemoryManager;

MemoryManager.prototype.createUI = function () {
  var viewer = this.viewer;
  var scope = this;

  this.panel = new _MemoryManagerUI__WEBPACK_IMPORTED_MODULE_0__["MemoryManagerPanel"](viewer);
  this.memMgrBtn = new avu.Button('toolbar-memMgrBtn');
  this.memMgrBtn.setToolTip('Memory Manager');
  this.memMgrBtn.setIcon("adsk-icon-mem-mgr");
  this.memMgrBtn.onClick = function (e) {
    var display = scope.panel.container.style.display === "none";
    // toggle
    if (display) {
      scope.activate();
    } else {
      scope.deactivate();
    }
  };

  viewer.modelTools.addControl(this.memMgrBtn);
};

MemoryManager.prototype.close = function () {
  this.panel.setVisible(false, true);
};

MemoryManager.prototype.load = function () {
  var viewer = this.viewer;
  var scope = this;

  function onToolbarCreated() {
    viewer.removeEventListener(av.TOOLBAR_CREATED_EVENT, onToolbarCreated);
    scope.createUI();
  }

  if (viewer.modelTools) {
    scope.createUI();
  } else {
    viewer.addEventListener(av.TOOLBAR_CREATED_EVENT, onToolbarCreated);
  }

  return true;
};

MemoryManager.prototype.unload = function () {
  var viewer = this.viewer;

  if (this.panel) {
    this.panel.setVisible(false);
    this.panel.uninitialize();
    this.panel = null;
  }

  viewer.modelTools.removeControl(this.memMgrBtn.getId());
  this.memMgrBtn = null;

  return true;
};

MemoryManager.prototype.activate = function () {
  if (!this.activeStatus) {
    this.panel.setVisible(true);
    this.activeStatus = true;
  }
  return true;
};

MemoryManager.prototype.deactivate = function () {
  if (this.activeStatus) {
    this.panel.setVisible(false);
    this.activeStatus = false;
  }
  return true;
};

av.theExtensionManager.registerExtension('Autodesk.Viewing.MemoryManager', MemoryManager);

/***/ }),

/***/ "./extensions/MemoryManager/MemoryManagerUI.css":
/*!******************************************************!*\
  !*** ./extensions/MemoryManager/MemoryManagerUI.css ***!
  \******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {


var content = __webpack_require__(/*! !../../node_modules/css-loader!./MemoryManagerUI.css */ "./node_modules/css-loader/index.js!./extensions/MemoryManager/MemoryManagerUI.css");

if(typeof content === 'string') content = [[module.i, content, '']];

var transform;
var insertInto;



var options = {"hmr":true}

options.transform = transform
options.insertInto = undefined;

var update = __webpack_require__(/*! ../../node_modules/style-loader/lib/addStyles.js */ "./node_modules/style-loader/lib/addStyles.js")(content, options);

if(content.locals) module.exports = content.locals;

if(false) {}

/***/ }),

/***/ "./extensions/MemoryManager/MemoryManagerUI.js":
/*!*****************************************************!*\
  !*** ./extensions/MemoryManager/MemoryManagerUI.js ***!
  \*****************************************************/
/*! exports provided: MemoryManagerPanel */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MemoryManagerPanel", function() { return MemoryManagerPanel; });
/* harmony import */ var _MemoryManagerUI_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./MemoryManagerUI.css */ "./extensions/MemoryManager/MemoryManagerUI.css");
/* harmony import */ var _MemoryManagerUI_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_MemoryManagerUI_css__WEBPACK_IMPORTED_MODULE_0__);



var av = Autodesk.Viewing,
ave = av.Extensions,
avu = av.UI;

var defaultSettings = {
  "memorymanager.unloadPackfiles": false,
  "memorymanager.sblIterator": false,
  "memorymanager.autoRefresh": false,
  "memorymanager.keepIdPixels": 1,
  "memorymanager.occludePixels": 1,
  "memorymanager.startOcclusionTesting": 8,
  "memorymanager.occlusionPackCount": 4,
  "memorymanager.occludeInstancing": true,
  "memorymanager.memorySize": 50,
  "memorymanager.maxPageOutSize": 50,
  "memorymanager.boxProxyMaxCount": 0,
  "memorymanager.boxProxyMinScreen": 0.4 };


var memoryId = "memory";
var occlusionId = "occlusion";
var debugId = "debug";

var showPFindex = -1;
var visiblePFs = "0";
var _refreshTimeout = 0;

function MemoryManagerPanel(viewer) {
  this.viewer = viewer;
  viewer.prefs.load(defaultSettings);

  function setSavedSettings() {
    var model = scope.viewer.model;
    if (model) {
      var prefs = scope.viewer.prefs;
      var pp = model.getFragmentList().pagingProxy;
      if (pp) {
        var options = pp.options;
        if (options.hasOwnProperty("limit"))
        options.limit = prefs.get("memorymanager.memorySize");
        if (options.debug.hasOwnProperty("maxPageOutSize"))
        options.debug.maxPageOutSize = prefs.get("memorymanager.maxPageOutSize");
        if (options.debug.hasOwnProperty("occlusionThreshold")) {
          options.debug.occlusionThreshold = prefs.get("memorymanager.keepIdPixels");
          scope.viewer.impl.renderer().settings.occlusionid = options.debug.occlusionThreshold > 0;
        }
        if (options.debug.hasOwnProperty("occlusionTestThreshold"))
        options.debug.occlusionTestThreshold = prefs.get("memorymanager.occludePixels");
        if (options.debug.hasOwnProperty("startOcclusionTestingPackCount"))
        options.debug.startOcclusionTestingPackCount = prefs.get("memorymanager.startOcclusionTesting");
        if (options.debug.hasOwnProperty("testPackfileCount"))
        options.debug.testPackfileCount = prefs.get("memorymanager.occlusionPackCount");
        if (options.debug.hasOwnProperty("useOcclusionInstancing"))
        options.debug.useOcclusionInstancing = prefs.get("memorymanager.occludeInstancing");
        if (options.debug.hasOwnProperty("boxProxyMaxCount"))
        options.debug.boxProxyMaxCount = prefs.get("memorymanager.boxProxyMaxCount");
        if (options.debug.hasOwnProperty("boxProxyMinScreen"))
        options.debug.boxProxyMinScreen = prefs.get("memorymanager.boxProxyMinScreen");
        if (options.debug.hasOwnProperty("automaticRefresh"))
        options.debug.automaticRefresh = prefs.get("memorymanager.autoRefresh");
      }
      scope.viewer.removeEventListener(Autodesk.Viewing.MODEL_ROOT_LOADED_EVENT, setSavedSettings);
    }
  }
  viewer.addEventListener(Autodesk.Viewing.MODEL_ROOT_LOADED_EVENT, setSavedSettings);

  var scope = this;
  var rightCellWidth = "200px";
  var margin = "7px";

  function addRow(tabId, caption, atIndex) {
    var value = document.createElement("div");
    scope.addControl(tabId, value, { caption: caption, insertAtIndex: atIndex });
    var cell = value.sliderRow.cells[1];
    cell.style.width = rightCellWidth;
    value.style.marginLeft = margin;
    value.style.marginRight = margin;
    return value;
  }

  function setupControl(controlId) {
    var control = scope.getControl(controlId);
    control.sliderRow.cells[1].style.width = rightCellWidth;
    return control;
  }

  function redrawView() {
    if (scope.model) {
      // just redraw
      scope.impl.invalidate(true, true, true);
    }
  }

  function getSortedPFid(pfIdIndex) {
    // -1 means don't use this feature to filter PFs
    if (pfIdIndex === -1)
    return -1;
    if (scope.viewer.model) {
      var pfOrder;
      var frags = scope.viewer.model.getFragmentList();
      if (frags && frags.pagingProxy && typeof frags.pagingProxy.pfOrder == 'function')
      pfOrder = frags.pagingProxy.pfOrder();
      return pfOrder ? pfOrder[pfIdIndex] : pfIdIndex;
    }
    return -1;
  }

  avu.SettingsPanel.call(this, viewer.container, 'MemoryManagePanel' + viewer.id, 'Memory Manager', { width: 380, heightAdjustment: 110 });

  this.addVisibilityListener(function (show) {
    if (show) {
      scope.refreshPanel();
      scope.resizeToContent();
    } else {
      if (_refreshTimeout > 0) {
        clearTimeout(_refreshTimeout);
        _refreshTimeout = 0;
      }
    }
  });

  this.container.dockRight = true;
  this.container.classList.add('memory-manager');

  this.addTab(memoryId, "Memory", { className: "mem-mgr-memory" });
  this.addTab(occlusionId, "Occlusion", { className: "mem-mgr-occlusion" });
  this.addTab(debugId, "Debug", { className: "mem-mgr-debug" });

  this.refreshDiv = document.createElement('div');
  this.refreshDiv.className = 'mem-mgr-reload';
  this.refreshDiv.textContent = "Refresh";
  this.addEventListener(this.refreshDiv, 'touchstart', av.touchStartToClick);
  this.addEventListener(this.refreshDiv, 'click', function () {
    if (scope.viewer.model) {
      resetForRefresh();
      scope.bboxCheckbox.setValue(false);
      scope.viewer.dispatchEvent({ type: av.LOAD_MISSING_GEOMETRY, delay: false, debug: {
          unloadPackFiles: !!scope.upfCheckbox.getValue() // For debugging only
        } });
      // view whole model, as viewing individual parts seems to be confusing the code
      // LMV-2188
      scope.showPFSlider.setValue(-1);
      updatePFstrat();
      scope.refreshPanel();
    }
  }, false);
  this.container.appendChild(this.refreshDiv);

  this.onDemandLoading = addRow(memoryId, "On Demand Loading", -1);
  this.packFileCount = addRow(memoryId, "Pack File Count", -1);
  this.geomMemorySize = addRow(memoryId, "Geom Memory Size", -1);
  this.memUsedSize = addRow(memoryId, "Memory Used", -1);
  this.lastPageOut = addRow(memoryId, "Last Page Out", -1);

  var prefs = viewer.prefs;
  this.autoCheckbox = setupControl(this.addCheckbox(debugId, "Auto Refresh",
  prefs.get("memorymanager.autoRefresh"), function (checked) {
    prefs.set("memorymanager.autoRefresh", checked);
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      if (pp)
      pp.options.debug.automaticRefresh = checked;
    }
  }));

  this.upfCheckbox = setupControl(this.addCheckbox(debugId, "Unload Packfiles",
  prefs.get("memorymanager.unloadPackfiles"), function (checked) {
    prefs.set("memorymanager.unloadPackfiles", checked);
  }));

  this.occtSlider = setupControl(this.addSlider(occlusionId, "Keep Id Pixels", 0, 4096,
  prefs.get("memorymanager.keepIdPixels"), function (e) {
    prefs.set("memorymanager.keepIdPixels", Number(scope.occtSlider.stepperElement.value));
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      var occlusionThreshold = Number(scope.occtSlider.stepperElement.value);
      if (pp)
      pp.options.debug.occlusionThreshold = occlusionThreshold;
      scope.viewer.impl.renderer().settings.occlusionid = occlusionThreshold > 0;
    }
  }));
  this.occtSlider.sliderElement.step = this.occtSlider.stepperElement.step = 1;

  this.poctSlider = setupControl(this.addSlider(occlusionId, "Pack Occluded Pixels", 0, 4096,
  prefs.get("memorymanager.occludePixels"), function (e) {
    prefs.set("memorymanager.occludePixels", Number(scope.poctSlider.stepperElement.value));
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      var occlusionTestThreshold = Number(scope.poctSlider.stepperElement.value);
      if (pp)
      pp.options.debug.occlusionTestThreshold = occlusionTestThreshold;
    }
  }));
  this.poctSlider.sliderElement.step = this.poctSlider.stepperElement.step = 1;

  this.socpSlider = setupControl(this.addSlider(occlusionId, "Start Occlusion", 0, 4096,
  prefs.get("memorymanager.startOcclusionTesting"), function (e) {
    prefs.set("memorymanager.startOcclusionTesting", Number(scope.socpSlider.stepperElement.value));
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      var startOcclusionTestingPackCount = Number(scope.socpSlider.stepperElement.value);
      if (pp)
      pp.options.debug.startOcclusionTestingPackCount = startOcclusionTestingPackCount;
    }
  }));
  this.socpSlider.sliderElement.step = this.socpSlider.stepperElement.step = 1;

  this.tstcSlider = setupControl(this.addSlider(occlusionId, "Occlusion Pack Count", 1, 4,
  prefs.get("memorymanager.occlusionPackCount"), function (e) {
    prefs.set("memorymanager.occlusionPackCount", Number(scope.tstcSlider.stepperElement.value));
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      var testPackfileCount = Number(scope.tstcSlider.stepperElement.value);
      if (pp)
      pp.options.debug.testPackfileCount = testPackfileCount;
    }
  }));
  this.tstcSlider.sliderElement.step = this.tstcSlider.stepperElement.step = 1;

  this.occInstCheckbox = setupControl(this.addCheckbox(occlusionId, "Occlusion Instancing",
  prefs.get("memorymanager.occludeInstancing"), function (checked) {
    prefs.set("memorymanager.occludeInstancing", checked);
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      if (pp)
      pp.options.debug.useOcclusionInstancing = checked;
    }
  }));

  this.occlusionCulledCount = addRow(memoryId, "Occlusion Culled Count", -1);

  this.pfSlider = setupControl(this.addSlider(memoryId, "Memory Limit MB", 10, 2050,
  prefs.get("memorymanager.memorySize"), function (e) {
    prefs.set("memorymanager.memorySize", Number(scope.pfSlider.stepperElement.value));
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      if (pp)
      pp.options.limit = Number(scope.pfSlider.stepperElement.value);
    }
  }));
  this.pfSlider.sliderElement.step = this.pfSlider.stepperElement.step = 10;

  this.maxPSlider = setupControl(this.addSlider(memoryId, "Max Page Out Size", 10, 2050,
  prefs.get("memorymanager.maxPageOutSize"), function (e) {
    prefs.set("memorymanager.maxPageOutSize", Number(scope.maxPSlider.stepperElement.value));
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      if (pp)
      pp.options.debug.maxPageOutSize = Number(scope.maxPSlider.stepperElement.value);
    }
  }));
  this.maxPSlider.sliderElement.step = this.maxPSlider.stepperElement.step = 10;

  this.pfCheckbox = setupControl(this.addCheckbox(debugId, "PF by importance", true,
  function () /*checked*/{
    updatePFstrat();
    redrawView();
  }));
  // Disable this control because RenderBatch.forEach and RenderBatchLess.forEach
  // no longer support showing a single pack file. Search for showPF to showPF
  // the lines that need to be uncommented to reenable it.
  this.pfCheckbox.checkElement.disabled = true;

  this.showPFSlider = setupControl(this.addSlider(debugId, "Show single PF", -1, 1500,
  -1, function (e) {
    if (scope.viewer.model) {
      var pp = scope.viewer.model.getFragmentList().pagingProxy;
      // Automatically refreshing the geometry interferes with displaying individual pack files
      // turn it off.
      if (pp)
      pp.options.debug.automaticRefresh = false;
    }
    updatePFstrat();
    redrawView();
  }));
  this.showPFSlider.sliderElement.step = this.showPFSlider.stepperElement.step = 1;
  // Disable this control because RenderBatch.forEach and RenderBatchLess.forEach
  // no longer support showing a single pack file. Search for showPF to showPF
  // the lines that need to be uncommented to reenable it.
  this.showPFSlider.sliderElement.disabled = this.showPFSlider.stepperElement.disabled = true;

  this.numBoxesSlider = setupControl(this.addSlider(debugId, "Proxy boxes", 0, 100000,
  prefs.get("memorymanager.boxProxyMaxCount"), function (e) {
    prefs.set("memorymanager.boxProxyMaxCount", Number(scope.numBoxesSlider.value));
    updatePFstrat();
    redrawView();
  }));
  this.numBoxesSlider.sliderElement.step = this.numBoxesSlider.stepperElement.step = 1;

  this.screenBoxesSlider = setupControl(this.addSlider(debugId, "Proxy screen area", 0, 4,
  prefs.get("memorymanager.boxProxyMinScreen"), function (e) {
    prefs.set("memorymanager.boxProxyMinScreen", Number(scope.screenBoxesSlider.value));
    updatePFstrat();
    redrawView();
  }));
  this.screenBoxesSlider.sliderElement.step = this.screenBoxesSlider.stepperElement.step = 0.1;

  this.bboxCheckbox = setupControl(this.addCheckbox(debugId, "Debug: bounding boxes", false,
  function (checked) {
    if (scope.viewer.model) {
      scope.viewer.model.getFragmentList().showBox = !!checked;
    }
    redrawView();
  }));
  // Disable this control because FragmentList.getVisibleMesh no longer supports showing boxes
  // for all geometry. Search for showBoxes for the lines that need to be uncommented to reenable it.
  this.bboxCheckbox.checkElement.disabled = true;

  this.pfStrategy = addRow(debugId, "Pack File Displayed", -1);

  this.refreshPanel();

  this.selectTab(memoryId);

  function resetForRefresh() {
    if (scope.viewer.model) {
      var frags = scope.viewer.model.getFragmentList();
      frags.showPF = -1;
      frags.showBox = false;
    }
  }

  function updatePFstrat() {
    showPFindex = Number(scope.showPFSlider.value);
    if (scope.viewer.model) {
      var frags = scope.viewer.model.getFragmentList();
      var pp = frags.pagingProxy;
      if (scope.pfCheckbox.getValue())
      frags.showPF = getSortedPFid(showPFindex);else

      frags.showPF = showPFindex;
      if (pp) {
        // update other values
        pp.options.debug.boxProxyMaxCount = Number(scope.numBoxesSlider.value);
        pp.options.debug.boxProxyMinScreen = Number(scope.screenBoxesSlider.value);
        scope.refreshPanel();
      }
    }
  }
}

MemoryManagerPanel.prototype = Object.create(avu.SettingsPanel.prototype);
MemoryManagerPanel.prototype.constructor = MemoryManagerPanel;

MemoryManagerPanel.prototype.refreshPanel = function (timer) {
  if (_refreshTimeout !== 0) {
    clearTimeout(_refreshTimeout);
    _refreshTimeout = 0;
  }
  _refreshTimeout = setTimeout(function (ui) {
    _refreshTimeout = 0;
    if (ui.isVisible())
    ui.refreshPanel(true);
  }, 1000, this);

  var onDemandLoading = "Unknown";
  var onDemandLoadingColor = "#ff0000";
  var packFileCount = "Unknown";
  var memorySize = "Unknown";
  var memoryUsed = "Unknown";
  var pageOut = "Unknown";
  var culledCount = "Unknown";
  var pfStrategy = "-1 / default";
  var pfMax = 1500;
  var model = this.viewer.model;

  function getNumVisiblePFs() {
    // -1 means unknown
    if (this.viewer.model) {
      var pfVisible;
      var frags = this.viewer.model.getFragmentList();
      if (frags && frags.pagingProxy && typeof frags.pagingProxy.pfOrder == 'function')
      pfVisible = frags.pagingProxy.getNumVisiblePFs();
      return pfVisible;
    }
    return -1;
  }

  if (model) {
    var memoryStats = model.getMemoryInfo();
    var loadedPackCount = -1;
    var packsPagedCount = -1;
    visiblePFs = getNumVisiblePFs.call(this);
    var frags = model.getFragmentList();
    if (frags) {
      onDemandLoading = frags.onDemandLoadingEnabled() ? "On" : "Off";
      if (frags.onDemandLoadingEnabled())
      onDemandLoadingColor = "";
      if (frags.pagingProxy) {
        this.bboxCheckbox.setValue(!!frags.showBox);
        this.occInstCheckbox.setValue(!!frags.pagingProxy.options.debug.useOcclusionInstancing);
        this.autoCheckbox.setValue(!!frags.pagingProxy.options.debug.automaticRefresh);
        if (!timer) {
          if (memoryStats)
          this.pfSlider.setValue(memoryStats.limit);
          if (frags.pagingProxy.options.debug.maxPageOutSize)
          this.maxPSlider.setValue(frags.pagingProxy.options.debug.maxPageOutSize);
          if (frags.pagingProxy.options.debug.occlusionThreshold)
          this.occtSlider.setValue(frags.pagingProxy.options.debug.occlusionThreshold);
          if (frags.pagingProxy.options.debug.occlusionTestThreshold)
          this.poctSlider.setValue(frags.pagingProxy.options.debug.occlusionTestThreshold);
          if (frags.pagingProxy.options.debug.startOcclusionTestingPackCount)
          this.socpSlider.setValue(frags.pagingProxy.options.debug.startOcclusionTestingPackCount);
          if (frags.pagingProxy.options.debug.testPackfileCount)
          this.tstcSlider.setValue(frags.pagingProxy.options.debug.testPackfileCount);
        }
        if (frags.pagingProxy.hasOwnProperty("totalGeomSize"))
        memorySize = frags.pagingProxy.totalGeomSize.toFixed(3) + " / limit " + memoryStats.effectiveLimit.toFixed(3);
        if (memoryStats)
        memoryUsed = memoryStats.loaded.toFixed(3);
        if (frags.pagingProxy.hasOwnProperty("loadedPacks"))
        loadedPackCount = Object.keys(frags.pagingProxy.loadedPacks).length;
        if (frags.pagingProxy.hasOwnProperty("packsPagedOut"))
        packsPagedCount = frags.pagingProxy.packsPagedOut;
        if (frags.pagingProxy.hasOwnProperty("lastPageOut"))
        pageOut = frags.pagingProxy.lastPageOut.toFixed(3);
        if (frags.pagingProxy.hasOwnProperty("occlusionCulledCount"))
        culledCount = frags.pagingProxy.occlusionCulledCount.toFixed(0);
      }

      var showPF = "all";
      if (frags.showPF !== -1) {
        var visPFs = parseInt(visiblePFs);
        if (showPFindex === -1) {
          showPF = "all";
        } else {
          showPF = frags.showPF;
          if (visPFs >= 0) {
            // valid to check for other status
            if (frags.pagingProxy.hasOwnProperty("loadedPacks") &&
            !frags.pagingProxy.loadedPacks[frags.showPF]) {
              // PF is not loaded or not visible, for some reason.
              showPF = showPF + " (not loaded)";
            }
            if (showPFindex >= visPFs) {
              // [] means nothing in PF is visible
              showPF = showPF + " (fully culled)";
            }
          }
        }
      }
      pfStrategy = showPF.toString();
    }
    if (model.is2d()) {
      packFileCount = "File is 2D";
    } else {
      var data = model.getData();
      if (data) {
        packFileCount = data.geompacks.length.toString();
        pfMax = packFileCount - 1;
      }
      if (visiblePFs >= 0)
      packFileCount += " / " + visiblePFs + " visible";
      if (loadedPackCount >= 0)
      memoryUsed += " / " + loadedPackCount + " loaded";
      if (packsPagedCount >= 0)
      pageOut += " / " + packsPagedCount + " packs paged out";

    }
  }
  this.onDemandLoading.setAttribute("data-i18n", onDemandLoading);
  this.onDemandLoading.textContent = av.i18n.translate(onDemandLoading);
  this.onDemandLoading.style.color = onDemandLoadingColor;
  this.packFileCount.setAttribute("data-i18n", packFileCount);
  this.packFileCount.textContent = av.i18n.translate(packFileCount);
  this.geomMemorySize.setAttribute("data-i18n", memorySize);
  this.geomMemorySize.textContent = av.i18n.translate(memorySize);
  this.memUsedSize.setAttribute("data-i18n", memoryUsed);
  this.memUsedSize.textContent = av.i18n.translate(memoryUsed);
  this.pfStrategy.setAttribute("data-i18n", pfStrategy);
  this.pfStrategy.textContent = av.i18n.translate(pfStrategy);
  this.lastPageOut.setAttribute("data-i18n", pageOut);
  this.lastPageOut.textContent = av.i18n.translate(pageOut);
  this.occlusionCulledCount.setAttribute("data-i18n", culledCount);
  this.occlusionCulledCount.textContent = av.i18n.translate(culledCount);

  // set to true range
  this.showPFSlider.sliderElement.max = pfMax;
  this.showPFSlider.stepperElement.max = pfMax;
};

/***/ }),

/***/ "./node_modules/css-loader/index.js!./extensions/MemoryManager/MemoryManagerUI.css":
/*!********************************************************************************!*\
  !*** ./node_modules/css-loader!./extensions/MemoryManager/MemoryManagerUI.css ***!
  \********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false);
// imports


// module
exports.push([module.i, ".adsk-viewing-viewer .mem-mgr-container {\r\n    width: 240px;\r\n    min-width: 240px;\r\n    top: 180px;\r\n    left: 220px;\r\n    line-height: 14px;\r\n    border-spacing: 1px;\r\n    border-collapse: separate;\r\n    resize: none;\r\n    background: rgba(34, 34, 34, 0.8);\r\n}\r\n\r\n.adsk-viewing-viewer .mem-mgr-content {\r\n    width: 100%;\r\n    height: calc(100% - 55px);\r\n    resize: none;\r\n    position: relative;\r\n}\r\n\r\n.adsk-viewing-viewer .mem-mgr-reload {\r\n    display: block;\r\n    font-size: 14px;\r\n    margin: 15px 20px 15px 21px;\r\n    padding: 6px 10px 6px 10px;\r\n    width: calc(100% - 60px);\r\n    cursor: pointer;\r\n    text-align: center;\r\n}\r\n\r\n.adsk-viewing-viewer .mem-mgr-reload:hover {\r\n    background-color: rgba(166,194,255, 0.7);\r\n    transition: all 0.2s ease;\r\n}\r\n\r\n.adsk-viewing-viewer .mem-mgr-status {\r\n    display: block;\r\n    font-size: 14px;\r\n    margin: 0px;\r\n    padding: 2px 10px;\r\n    width: calc(100% - 60px);\r\n    height: 28px;\r\n    cursor: pointer;\r\n    text-align: left;\r\n    white-space: pre;\r\n}\r\n\r\n.adsk-viewing-viewer .mem-mgr-memory td > input[id$=\"_stepper\"], .mem-mgr-occlusion td > input[id$=\"_stepper\"], .mem-mgr-debug td > input[id$=\"_stepper\"] {\r\n    color: initial;\r\n}\r\n\r\n.adsk-viewing-viewer .memory-manager {\r\n    max-width: 380px !important;\r\n}\r\n\r\n.adsk-viewing-viewer .memory-manager .settings-tabs ul li,\r\n.adsk-viewing-viewer .memory-manager .settings-tabs ul li a {\r\n    width: 33%;\r\n}\r\n\r\n.adsk-viewing-viewer .memory-manager .mem-mgr-occlusion a {\r\n    text-align: center;\r\n}\r\n\r\n.adsk-viewing-viewer .memory-manager .docking-panel-scroll {\r\n    top: 40px;\r\n}\r\n\r\n.adsk-viewing-viewer .memory-manager .switch {\r\n    margin-left: 25px;\r\n}\r\n\r\n.adsk-viewing-viewer .memory-manager .switch .slider {\r\n    width: 26px;\r\n}", ""]);

// exports


/***/ }),

/***/ "./node_modules/css-loader/lib/css-base.js":
/*!*************************************************!*\
  !*** ./node_modules/css-loader/lib/css-base.js ***!
  \*************************************************/
/*! no static exports found */
/***/ (function(module, exports) {

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function(useSourceMap) {
	var list = [];

	// return the list of modules as css string
	list.toString = function toString() {
		return this.map(function (item) {
			var content = cssWithMappingToString(item, useSourceMap);
			if(item[2]) {
				return "@media " + item[2] + "{" + content + "}";
			} else {
				return content;
			}
		}).join("");
	};

	// import a list of modules into the list
	list.i = function(modules, mediaQuery) {
		if(typeof modules === "string")
			modules = [[null, modules, ""]];
		var alreadyImportedModules = {};
		for(var i = 0; i < this.length; i++) {
			var id = this[i][0];
			if(typeof id === "number")
				alreadyImportedModules[id] = true;
		}
		for(i = 0; i < modules.length; i++) {
			var item = modules[i];
			// skip already imported module
			// this implementation is not 100% perfect for weird media query combinations
			//  when a module is imported multiple times with different media queries.
			//  I hope this will never occur (Hey this way we have smaller bundles)
			if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
				if(mediaQuery && !item[2]) {
					item[2] = mediaQuery;
				} else if(mediaQuery) {
					item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
				}
				list.push(item);
			}
		}
	};
	return list;
};

function cssWithMappingToString(item, useSourceMap) {
	var content = item[1] || '';
	var cssMapping = item[3];
	if (!cssMapping) {
		return content;
	}

	if (useSourceMap && typeof btoa === 'function') {
		var sourceMapping = toComment(cssMapping);
		var sourceURLs = cssMapping.sources.map(function (source) {
			return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
		});

		return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
	}

	return [content].join('\n');
}

// Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
	// eslint-disable-next-line no-undef
	var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
	var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;

	return '/*# ' + data + ' */';
}


/***/ }),

/***/ "./node_modules/style-loader/lib/addStyles.js":
/*!****************************************************!*\
  !*** ./node_modules/style-loader/lib/addStyles.js ***!
  \****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/

var stylesInDom = {};

var	memoize = function (fn) {
	var memo;

	return function () {
		if (typeof memo === "undefined") memo = fn.apply(this, arguments);
		return memo;
	};
};

var isOldIE = memoize(function () {
	// Test for IE <= 9 as proposed by Browserhacks
	// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
	// Tests for existence of standard globals is to allow style-loader
	// to operate correctly into non-standard environments
	// @see https://github.com/webpack-contrib/style-loader/issues/177
	return window && document && document.all && !window.atob;
});

var getTarget = function (target, parent) {
  if (parent){
    return parent.querySelector(target);
  }
  return document.querySelector(target);
};

var getElement = (function (fn) {
	var memo = {};

	return function(target, parent) {
                // If passing function in options, then use it for resolve "head" element.
                // Useful for Shadow Root style i.e
                // {
                //   insertInto: function () { return document.querySelector("#foo").shadowRoot }
                // }
                if (typeof target === 'function') {
                        return target();
                }
                if (typeof memo[target] === "undefined") {
			var styleTarget = getTarget.call(this, target, parent);
			// Special case to return head of iframe instead of iframe itself
			if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
				try {
					// This will throw an exception if access to iframe is blocked
					// due to cross-origin restrictions
					styleTarget = styleTarget.contentDocument.head;
				} catch(e) {
					styleTarget = null;
				}
			}
			memo[target] = styleTarget;
		}
		return memo[target]
	};
})();

var singleton = null;
var	singletonCounter = 0;
var	stylesInsertedAtTop = [];

var	fixUrls = __webpack_require__(/*! ./urls */ "./node_modules/style-loader/lib/urls.js");

module.exports = function(list, options) {
	if (typeof DEBUG !== "undefined" && DEBUG) {
		if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
	}

	options = options || {};

	options.attrs = typeof options.attrs === "object" ? options.attrs : {};

	// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
	// tags it will allow on a page
	if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();

	// By default, add <style> tags to the <head> element
        if (!options.insertInto) options.insertInto = "head";

	// By default, add <style> tags to the bottom of the target
	if (!options.insertAt) options.insertAt = "bottom";

	var styles = listToStyles(list, options);

	addStylesToDom(styles, options);

	return function update (newList) {
		var mayRemove = [];

		for (var i = 0; i < styles.length; i++) {
			var item = styles[i];
			var domStyle = stylesInDom[item.id];

			domStyle.refs--;
			mayRemove.push(domStyle);
		}

		if(newList) {
			var newStyles = listToStyles(newList, options);
			addStylesToDom(newStyles, options);
		}

		for (var i = 0; i < mayRemove.length; i++) {
			var domStyle = mayRemove[i];

			if(domStyle.refs === 0) {
				for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();

				delete stylesInDom[domStyle.id];
			}
		}
	};
};

function addStylesToDom (styles, options) {
	for (var i = 0; i < styles.length; i++) {
		var item = styles[i];
		var domStyle = stylesInDom[item.id];

		if(domStyle) {
			domStyle.refs++;

			for(var j = 0; j < domStyle.parts.length; j++) {
				domStyle.parts[j](item.parts[j]);
			}

			for(; j < item.parts.length; j++) {
				domStyle.parts.push(addStyle(item.parts[j], options));
			}
		} else {
			var parts = [];

			for(var j = 0; j < item.parts.length; j++) {
				parts.push(addStyle(item.parts[j], options));
			}

			stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
		}
	}
}

function listToStyles (list, options) {
	var styles = [];
	var newStyles = {};

	for (var i = 0; i < list.length; i++) {
		var item = list[i];
		var id = options.base ? item[0] + options.base : item[0];
		var css = item[1];
		var media = item[2];
		var sourceMap = item[3];
		var part = {css: css, media: media, sourceMap: sourceMap};

		if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
		else newStyles[id].parts.push(part);
	}

	return styles;
}

function insertStyleElement (options, style) {
	var target = getElement(options.insertInto)

	if (!target) {
		throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
	}

	var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];

	if (options.insertAt === "top") {
		if (!lastStyleElementInsertedAtTop) {
			target.insertBefore(style, target.firstChild);
		} else if (lastStyleElementInsertedAtTop.nextSibling) {
			target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
		} else {
			target.appendChild(style);
		}
		stylesInsertedAtTop.push(style);
	} else if (options.insertAt === "bottom") {
		target.appendChild(style);
	} else if (typeof options.insertAt === "object" && options.insertAt.before) {
		var nextSibling = getElement(options.insertAt.before, target);
		target.insertBefore(style, nextSibling);
	} else {
		throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
	}
}

function removeStyleElement (style) {
	if (style.parentNode === null) return false;
	style.parentNode.removeChild(style);

	var idx = stylesInsertedAtTop.indexOf(style);
	if(idx >= 0) {
		stylesInsertedAtTop.splice(idx, 1);
	}
}

function createStyleElement (options) {
	var style = document.createElement("style");

	if(options.attrs.type === undefined) {
		options.attrs.type = "text/css";
	}

	if(options.attrs.nonce === undefined) {
		var nonce = getNonce();
		if (nonce) {
			options.attrs.nonce = nonce;
		}
	}

	addAttrs(style, options.attrs);
	insertStyleElement(options, style);

	return style;
}

function createLinkElement (options) {
	var link = document.createElement("link");

	if(options.attrs.type === undefined) {
		options.attrs.type = "text/css";
	}
	options.attrs.rel = "stylesheet";

	addAttrs(link, options.attrs);
	insertStyleElement(options, link);

	return link;
}

function addAttrs (el, attrs) {
	Object.keys(attrs).forEach(function (key) {
		el.setAttribute(key, attrs[key]);
	});
}

function getNonce() {
	if (false) {}

	return __webpack_require__.nc;
}

function addStyle (obj, options) {
	var style, update, remove, result;

	// If a transform function was defined, run it on the css
	if (options.transform && obj.css) {
	    result = typeof options.transform === 'function'
		 ? options.transform(obj.css) 
		 : options.transform.default(obj.css);

	    if (result) {
	    	// If transform returns a value, use that instead of the original css.
	    	// This allows running runtime transformations on the css.
	    	obj.css = result;
	    } else {
	    	// If the transform function returns a falsy value, don't add this css.
	    	// This allows conditional loading of css
	    	return function() {
	    		// noop
	    	};
	    }
	}

	if (options.singleton) {
		var styleIndex = singletonCounter++;

		style = singleton || (singleton = createStyleElement(options));

		update = applyToSingletonTag.bind(null, style, styleIndex, false);
		remove = applyToSingletonTag.bind(null, style, styleIndex, true);

	} else if (
		obj.sourceMap &&
		typeof URL === "function" &&
		typeof URL.createObjectURL === "function" &&
		typeof URL.revokeObjectURL === "function" &&
		typeof Blob === "function" &&
		typeof btoa === "function"
	) {
		style = createLinkElement(options);
		update = updateLink.bind(null, style, options);
		remove = function () {
			removeStyleElement(style);

			if(style.href) URL.revokeObjectURL(style.href);
		};
	} else {
		style = createStyleElement(options);
		update = applyToTag.bind(null, style);
		remove = function () {
			removeStyleElement(style);
		};
	}

	update(obj);

	return function updateStyle (newObj) {
		if (newObj) {
			if (
				newObj.css === obj.css &&
				newObj.media === obj.media &&
				newObj.sourceMap === obj.sourceMap
			) {
				return;
			}

			update(obj = newObj);
		} else {
			remove();
		}
	};
}

var replaceText = (function () {
	var textStore = [];

	return function (index, replacement) {
		textStore[index] = replacement;

		return textStore.filter(Boolean).join('\n');
	};
})();

function applyToSingletonTag (style, index, remove, obj) {
	var css = remove ? "" : obj.css;

	if (style.styleSheet) {
		style.styleSheet.cssText = replaceText(index, css);
	} else {
		var cssNode = document.createTextNode(css);
		var childNodes = style.childNodes;

		if (childNodes[index]) style.removeChild(childNodes[index]);

		if (childNodes.length) {
			style.insertBefore(cssNode, childNodes[index]);
		} else {
			style.appendChild(cssNode);
		}
	}
}

function applyToTag (style, obj) {
	var css = obj.css;
	var media = obj.media;

	if(media) {
		style.setAttribute("media", media)
	}

	if(style.styleSheet) {
		style.styleSheet.cssText = css;
	} else {
		while(style.firstChild) {
			style.removeChild(style.firstChild);
		}

		style.appendChild(document.createTextNode(css));
	}
}

function updateLink (link, options, obj) {
	var css = obj.css;
	var sourceMap = obj.sourceMap;

	/*
		If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
		and there is no publicPath defined then lets turn convertToAbsoluteUrls
		on by default.  Otherwise default to the convertToAbsoluteUrls option
		directly
	*/
	var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;

	if (options.convertToAbsoluteUrls || autoFixUrls) {
		css = fixUrls(css);
	}

	if (sourceMap) {
		// http://stackoverflow.com/a/26603875
		css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
	}

	var blob = new Blob([css], { type: "text/css" });

	var oldSrc = link.href;

	link.href = URL.createObjectURL(blob);

	if(oldSrc) URL.revokeObjectURL(oldSrc);
}


/***/ }),

/***/ "./node_modules/style-loader/lib/urls.js":
/*!***********************************************!*\
  !*** ./node_modules/style-loader/lib/urls.js ***!
  \***********************************************/
/*! no static exports found */
/***/ (function(module, exports) {


/**
 * When source maps are enabled, `style-loader` uses a link element with a data-uri to
 * embed the css on the page. This breaks all relative urls because now they are relative to a
 * bundle instead of the current page.
 *
 * One solution is to only use full urls, but that may be impossible.
 *
 * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
 *
 * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
 *
 */

module.exports = function (css) {
  // get current location
  var location = typeof window !== "undefined" && window.location;

  if (!location) {
    throw new Error("fixUrls requires window.location");
  }

	// blank or null?
	if (!css || typeof css !== "string") {
	  return css;
  }

  var baseUrl = location.protocol + "//" + location.host;
  var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");

	// convert each url(...)
	/*
	This regular expression is just a way to recursively match brackets within
	a string.

	 /url\s*\(  = Match on the word "url" with any whitespace after it and then a parens
	   (  = Start a capturing group
	     (?:  = Start a non-capturing group
	         [^)(]  = Match anything that isn't a parentheses
	         |  = OR
	         \(  = Match a start parentheses
	             (?:  = Start another non-capturing groups
	                 [^)(]+  = Match anything that isn't a parentheses
	                 |  = OR
	                 \(  = Match a start parentheses
	                     [^)(]*  = Match anything that isn't a parentheses
	                 \)  = Match a end parentheses
	             )  = End Group
              *\) = Match anything and then a close parens
          )  = Close non-capturing group
          *  = Match anything
       )  = Close capturing group
	 \)  = Match a close parens

	 /gi  = Get all matches, not the first.  Be case insensitive.
	 */
	var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
		// strip quotes (if they exist)
		var unquotedOrigUrl = origUrl
			.trim()
			.replace(/^"(.*)"$/, function(o, $1){ return $1; })
			.replace(/^'(.*)'$/, function(o, $1){ return $1; });

		// already a full url? no change
		if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
		  return fullMatch;
		}

		// convert the url to a full url
		var newUrl;

		if (unquotedOrigUrl.indexOf("//") === 0) {
		  	//TODO: should we add protocol?
			newUrl = unquotedOrigUrl;
		} else if (unquotedOrigUrl.indexOf("/") === 0) {
			// path should be relative to the base url
			newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
		} else {
			// path should be relative to current directory
			newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
		}

		// send back the fixed url(...)
		return "url(" + JSON.stringify(newUrl) + ")";
	});

	// send back the fixed css
	return fixedCss;
};


/***/ })

/******/ });